package com.study.stream.jack;

import com.alibaba.fastjson.JSON;
import com.study.vo.StudyMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.messaging.handler.annotation.Payload;

/**
 * 自定义的输入信道、消息接收
 */
@Slf4j
@EnableBinding(JackSink.class)
public class JackReceiveService {

    @StreamListener(JackSink.INPUT)
    public void receivemessage(@Payload Object payload){

        log.info("JackReceiveService consume message start");

        StudyMessage message = JSON.parseObject(
                payload.toString(),StudyMessage.class
        );

        log.info("JackReceiveService consume message 成功 :[{}]",
                JSON.toJSONString(message));

    }
}
